package dao

import (
	"fmt"
	"github.com/jinzhu/gorm"
	"time"
)

var (
	DB *gorm.DB
)

func InitMysql()(err error)  {
	DB,err = gorm.Open("mysql","root:yourPasswd@(localhost)/DBName?charset=utf8mb4&parseTime=True&loc=Local")
	if err!=nil{
		panic(err)
	}
	return DB.DB().Ping()
}

//获取昨天和今天的时间
func GetTime()(yesterday,today string)  {
	month := time.Now().Month()
	day := time.Now().Day()
	yesterday = fmt.Sprintf("%d-%d",month,day-1)
	today = fmt.Sprintf("%d-%d",month,day)
	//fmt.Println(yesterday,today)
	return
}


